package com.kapcb.statemachine.builder;

import com.kapcb.statemachine.State;
import com.kapcb.statemachine.impl.StateHelper;
import com.kapcb.statemachine.impl.TransitionType;

import java.util.List;
import java.util.Map;

/**
 * <a>Title: AbstractParallelTransitionBuilder </a>
 * <a>Author: Kapcb <a>
 * <a>Description: AbstractParallelTransitionBuilder <a>
 *
 * @author Kapcb
 * @version 1.0
 * @date 2024/7/26 22:27
 * @since 1.0
 */
public abstract class AbstractParallelTransitionBuilder<S, E, C> implements ParallelFrom<S, E, C>, On<S, E, C>, To<S, E, C> {

    final Map<S, State<S, E, C>> stateMap;

    protected List<State<S, E, C>> targets;

    final TransitionType transitionType;

    public AbstractParallelTransitionBuilder(Map<S, State<S, E, C>> stateMap, TransitionType transitionType) {
        this.stateMap = stateMap;
        this.transitionType = transitionType;
    }

    @Override
    public To<S, E, C> toAmong(S... stateIds) {
        targets = StateHelper.getStates(stateMap, stateIds);
        return this;
    }

}
